// @flow
import type { TurboModule } from 'react-native/Libraries/TurboModule/RCTExport';
import { TurboModuleRegistry } from 'react-native';

/// Send messages to Android side
export interface Spec extends TurboModule {
  onMounted(): void;
  onClick(x: number, y: number): void;
  onStop(): void;
  getOrientation(): Promise<number>;

  /**
   * Register button click
   * Registered buttons will appear in sidebar and lasso toolbar
   * @param {int} type menuItem type, 1: Sidebar button 2: Lasso toolbar button
   * @param {Object} menuItem Button data, divided into sidebar and lasso toolbar data
   * Sidebar button data:
   * {
   * id: Button ID, unique and immutable, defined by plugin
   * name: Button name
   * color: Font color
   * icon: Button icon
   * bgColor: Background color
   * expandMenuItem: Whether to extend existing buttons, only for sidebar
   *  0: default, no extension, adds entry to sidebar
   *  1: pen
   *  2: eraser
   *  3: layer
   *  4: template
   *  5: thumbnail
   * }
   *
   * Lasso toolbar button data:
   * {
   * id: Button ID, unique and immutable, defined by plugin
   * name: Button name
   * color: Font color
   * icon: Button icon
   * bgColor: Background color
   * editDataTypes: List<Integer> Current lasso data types that show toolbar
   *   0: Handwritten strokes
   *   1: Title
   *   2: Image
   *   3: Text
   *   4: Link
   * isHideToolbar: Whether to hide toolbar after click
   * }
   * 
   * @param {Object} showData UI display data after button click, can be null
   * {
   * regionType: Plugin display area type
   *   0: No UI display needed
   *   1: Center dialog display
   *   2: Fullscreen display
   *   3: Fullscreen display, won't dismiss
   * regionWidth: Area width
   * regionHeight: Area height
   * }
   */
  registerMenuItemRes(type: number, menuItem: Object, showData: ?Object): Promise<boolean>;

  /**
   * Register button submenu
   * @param {Object} menuItem Button data, divided into sidebar and lasso toolbar data
   * Sidebar button data:
   * {
   * parentId: Parent button ID
   * id: Button ID, unique and immutable, defined by plugin
   * name: Button name
   * color: Font color
   * icon: Button icon
   * bgColor: Background color
   * }
   *
   * Lasso toolbar button data:
   * {
   * parentId: Parent button ID
   * id: Button ID, unique and immutable, defined by plugin
   * name: Button name
   * color: Font color
   * icon: Button icon
   * bgColor: Background color
   * }
   * 
   * @param {Object} showData UI display data after button click, can be null
   * {
   * regionType: Plugin display area type
   *   0: No UI display needed
   *   1: Center dialog display
   *   2: Fullscreen display
   *   3: Fullscreen display, won't dismiss
   * regionWidth: Area width
   * regionHeight: Area height
   * }
   */
  registerSubMenuItemRes(menuItem: Object, showData: ?Object): Promise<boolean>;

  /**
   * Unregister menu button
   * @param {int} id Button ID
   */
  unregisterMenuItemRes(id:number):Promise<boolean>;

  /**
   * Modify button properties
   * @param {Object} menuItem Button data format:
   * {
   * id: Button ID, unique and immutable, defined by plugin, identifies which button to modify
   * name: Button name
   * color: Font color
   * icon: Button icon
   * bgColor: Background color
   * }
   */
  modifyMenuItem(menuItem:Object, showData:?Object):Promise<boolean>;

  /**
   * Actively show plugin view
   * @param {Object} showData 
   * UI data, cannot be null, only types 1 and 2 allowed
   * {
   * regionType: Plugin display area type
   *   1: Dialog display
   *   2: Fullscreen display
   * regionWidth: Area width
   * regionHeight: Area height
   * }
   */
  showPluginView(showData:Object):Promise<boolean>;

  /**
   * Actively close plugin UI
   */
  closePluginView():Promise<boolean>;

  /**
   * Set lasso box state
   * 0: Show, 1: Hide, 2: Completely remove
   * @param {int} state 
   */
  setLassoBoxSate(state:number):Promise<boolean>;

  /**
   * Set slider bar status
   * @param {boolean} status true: Slidable, false: Not slidable
   */
  setSlideBarStatus(status:boolean):Promise<boolean>;

  /**
   * Register config button
   * @param {Object} showData UI display data after button click, cannot be null:
   * {
   * regionType: Plugin display area type
   *   0: No UI display needed
   *   1: Center dialog display
   *   2: Fullscreen display
   *   3: Fullscreen display, won't dismiss
   * regionWidth: Area width
   * regionHeight: Area height
   * }
   */
  registerConfigButtonRes(showData:Object):Promise<boolean>;

  // Refresh plugin view
  invalidatePluginView():void;

  /**
   * 设置系统休眠状态
   * @param {boolean} enable true:阻止系统修复，false:开启休眠
   */
  setSystemDormancyState(enable:boolean):void;

  /**
   *设置下来菜单和滑条状态
   * @param {boolean} isLock true:锁住，不可使用，false：解锁，可以使用 
   *   */ 
  setStatusBarAndSlideBarState(isLock:boolean):void;


}

export default (TurboModuleRegistry.get < Spec > (
  'RTNEvent'
):?Spec);